package com.blank.web.servlet;

import com.blank.web.bean.Student;
import com.blank.web.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "updateStuServlet",urlPatterns = "/updateServlet")
public class updateStuServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       int sid =Integer.parseInt(request.getParameter("sid"));
        StudentService studentService = new StudentService();
        Student student = studentService.findStudentById(sid);
        request.setAttribute("student",student);
        request.getRequestDispatcher("updateStudentInfo.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
